package com.otp.service.util;

import java.text.DecimalFormat;

public class FormatScoreUtil {

	public static String formatScoresPerCent(Double dbl, int decimals){	
		DecimalFormat df;
		if(dbl==null) return "";
		dbl*=100.;
		switch(decimals){
		case 0:
			df = new DecimalFormat("#");
			return df.format(dbl)+"%";
		case 1:
			df = new DecimalFormat("0.0");
			return df.format(dbl)+"%";
		case 2:
			df = new DecimalFormat("0.00");
			return df.format(dbl)+"%";
		default:
			return dbl+"%";
		}
	}

	public static String formatScores(Double dbl, int decimals){	
		DecimalFormat df;
		if(dbl==null) return "";
		switch(decimals){
		case 0:
			df = new DecimalFormat("#");
			return df.format(dbl);
		case 1:
			df = new DecimalFormat("0.0");
			return df.format(dbl);
		case 2:
			df = new DecimalFormat("0.00");
			return df.format(dbl);
		case 3:
			df = new DecimalFormat("0.000");
			return df.format(dbl);
		default:
			return dbl+"";
		}
	}

}
